package com.example.springbootdemo.bean.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author hh
 * @since 2022-01-19
 */
@ApiModel(value = "User对象", description = "")
@Document(indexName = "user")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    @Id
    private Integer id;

    @Excel(name = "用户名", width = 15, isImportField = "true")
    @ApiModelProperty("用户名")
    private String name;

    @ApiModelProperty("密码")
    private String password;

    @Excel(name = "性别", orderNum = "1", width = 15, replace = {"男_0", "女_1"}, isImportField = "true")
    @ApiModelProperty("性别。0：男，1：女")
    @Field(type = FieldType.Integer)
    private Integer gender;

    @Excel(name = "年龄", orderNum = "2", width = 15, isImportField = "true")
    @ApiModelProperty("年龄")
    @Field(type = FieldType.Integer)
    private Integer age;

    @Excel(name = "电话", orderNum = "3", width = 17, isImportField = "true")
    @ApiModelProperty("电话")
    private String tel;

    @Excel(name = "邮箱", orderNum = "4", width = 17, isImportField = "true")
    @ApiModelProperty("邮箱")
    private String email;

    @Excel(name = "用户角色", orderNum = "5", width = 15)
    @ApiModelProperty("用户角色")
    private String role;

    @ApiModelProperty(value = "逻辑删除。0：未删除，1：已删除", hidden = true)
    @TableLogic
    @Field(type = FieldType.Integer)
    private Integer isDeleted;

    @ApiModelProperty(value = "更新时间", hidden = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second)
    private LocalDateTime updateTime;

    @Excel(name = "创建时间", format = "yyyy-MM-dd HH:mm:ss",orderNum = "6", width = 30, isImportField = "true")
    @ApiModelProperty(value = "创建时间", hidden = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",  timezone = "GMT+8")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second)
    private LocalDateTime createTime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public Integer getGender() {
        return gender;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }
    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public Integer getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }
    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "User{" +
            "id=" + id +
            ", name=" + name +
            ", gender=" + gender +
            ", age=" + age +
            ", tel=" + tel +
            ", email=" + email +
            ", isDeleted=" + isDeleted +
            ", updateTime=" + updateTime +
            ", createTime=" + createTime +
        "}";
    }
}
